package com.cmwa.solution.sys.msg.service.impl;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cmwa.solution.base.dao.BaseDao;
import com.cmwa.solution.base.service.impl.BaseServiceImpl;
import com.cmwa.solution.sys.msg.dao.IMsgWaitSendDao;
import com.cmwa.solution.sys.msg.service.IMsgWaitSendService;
import com.cmwa.solution.sys.msg.vo.MsgWaitSendVo;

@Service
@SuppressWarnings({"rawtypes", "unchecked"})
public class MsgWaiSendServiceImpl extends BaseServiceImpl<MsgWaitSendVo> implements IMsgWaitSendService{
	@Resource
	private IMsgWaitSendDao msgWaitSendDao;

	public BaseDao<MsgWaitSendVo> getDao() {
		return msgWaitSendDao;
	}

	@Override
	public boolean lockNewEmail(String[] ids) {
		int rst = 0;
		if(ids!=null && ids.length>0){
			rst = msgWaitSendDao.lockNewEmail(ids);
		}
		if(rst>0){
			return true;
		}else{
			return false;
		}
	}

	@Override
	public void transferEmailBackup(String[] normalIds, String[] exceptionIds, String[] ids,String msgBatchId) {
		if(normalIds!=null && normalIds.length>0){
			Map normalParam=new HashMap();
			normalParam.put("normalIds", normalIds);
			normalParam.put("msgBatchId", msgBatchId);
			msgWaitSendDao.transferNormalEmailBackup(normalParam);
		}
		if(exceptionIds!=null && exceptionIds.length>0){
			Map exceptionParam=new HashMap();
			exceptionParam.put("exceptionIds", exceptionIds);
			exceptionParam.put("msgBatchId", msgBatchId);
			msgWaitSendDao.transferExceptionEmailBackup(exceptionParam);
		}
		if(ids!=null && ids.length>0){
			msgWaitSendDao.deleteEmails(ids);
		}
	}
	
}
